package com.pro.staffmanage.utils;

import javax.sql.DataSource;
import java.sql.SQLException;

public class DataBaseUtil {

    /**
     * 查看 dataSource 数据源中是否存在名为 tableName 的表
     *
     * @param tableName
     * @param dataSource
     * @return
     * @throws SQLException
     */
    public static boolean validateTableNameExist(String tableName, DataSource dataSource) throws SQLException {
        return dataSource
                .getConnection()
                .getMetaData()
                .getTables(null, null, tableName, null)
                .next();
    }

}
